package com.burgeon.backend.Controller;


import com.burgeon.backend.entity.TemplateSwitch;
import com.burgeon.backend.mappers.AccountMapper;
import com.burgeon.backend.service.ActivityService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@CrossOrigin
@RequestMapping("activity")
public class ActivityController extends BaseController{
    @Autowired
    private ActivityService activityService;
    @Autowired
    private AccountMapper accountMapper;

    @RequestMapping("getdata")
    public ResponseResult<TemplateSwitch> GetData(String account){
       // String account = session.getAttribute("account").toString();
        TemplateSwitch data = activityService.GetSwitchData(account);
        return new ResponseResult<>(SUCCESS, data);
    }

    @RequestMapping("updata")
    public ResponseResult<Void> UpData(TemplateSwitch templateSwitch,String account){
        System.err.println(templateSwitch);
       // String account = session.getAttribute("account").toString();
        templateSwitch.setAccount(account);

        templateSwitch.setToken(account);
        activityService.UpDataSwitch(templateSwitch);
        return new ResponseResult<>(SUCCESS);
    }

}
